package org.kabeja.parser.entities;

import org.kabeja.dxf.entity.DXFEntity;
import org.kabeja.dxf.entity.DXFSolid;
import org.kabeja.parser.DXFValue;

/**
 * @author shutao
 * @since 2022/4/25 11:54
 */
public class DXFSolidHandler extends AbstractEntityHandler {
    public static final int POINT2_X = 11;
    public static final int POINT2_Y = 21;
    public static final int POINT2_Z = 31;
    public static final int POINT3_X = 12;
    public static final int POINT3_Y = 22;
    public static final int POINT3_Z = 32;
    public static final int POINT4_X = 13;
    public static final int POINT4_Y = 23;
    public static final int POINT4_Z = 33;
    protected String ENTITY_NAME = "SOLID";
    protected DXFSolid solid;

    public DXFSolidHandler() {
    }

    @Override
    public void endDXFEntity() {
    }

    @Override
    public DXFEntity getDXFEntity() {
        return this.solid;
    }

    @Override
    public String getDXFEntityName() {
        return this.ENTITY_NAME;
    }

    @Override
    public boolean isFollowSequence() {
        return false;
    }

    @Override
    public void parseGroup(int var1, DXFValue var2) {
        switch(var1) {
            case 10:
                this.solid.getPoint1().setX(var2.getDoubleValue());
                break;
            case 11:
                this.solid.getPoint2().setX(var2.getDoubleValue());
                break;
            case 12:
                this.solid.getPoint3().setX(var2.getDoubleValue());
                break;
            case 13:
                this.solid.getPoint4().setX(var2.getDoubleValue());
                break;
            case 14:
            case 15:
            case 16:
            case 17:
            case 18:
            case 19:
            case 24:
            case 25:
            case 26:
            case 27:
            case 28:
            case 29:
            default:
                super.parseCommonProperty(var1, var2, this.solid);
                break;
            case 20:
                this.solid.getPoint1().setY(var2.getDoubleValue());
                break;
            case 21:
                this.solid.getPoint2().setY(var2.getDoubleValue());
                break;
            case 22:
                this.solid.getPoint3().setY(var2.getDoubleValue());
                break;
            case 23:
                this.solid.getPoint4().setY(var2.getDoubleValue());
                break;
            case 30:
                this.solid.getPoint1().setZ(var2.getDoubleValue());
                break;
            case 31:
                this.solid.getPoint2().setZ(var2.getDoubleValue());
                break;
            case 32:
                this.solid.getPoint3().setZ(var2.getDoubleValue());
                break;
            case 33:
                this.solid.getPoint4().setZ(var2.getDoubleValue());
        }

    }

    @Override
    public void parseObject(int var1, DXFValue var2, int type) {
        super.parseObjectProperty(var1, var2, type, this.solid);
    }

    @Override
    public void startDXFEntity() {
        this.solid = new DXFSolid();
    }
}
